package com.buaa.hyf.activity;

import android.graphics.drawable.BitmapDrawable;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.GridView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.buaa.hyf.adapter.GrideAdapter;
import com.buaa.hyf.util.Globals;
import com.buaa.hyf.util.ImageUtil;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class MainActivity extends AppCompatActivity {

    private TextView topstar;
    private LinearLayout topbar;
    private List<Map<String,Object>> values;
    private GridView grid;
    private GrideAdapter adapter;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        topstar = (TextView) findViewById(R.id.top_star);
        topbar = (LinearLayout) findViewById(R.id.top_bar);
        grid = (GridView) findViewById(R.id.grid);

        topbar.setBackgroundDrawable(new BitmapDrawable(getResources(), ImageUtil.getTopBar()));
        topstar.setBackgroundDrawable(new BitmapDrawable(getResources(), ImageUtil.getTopStart()));
        int nowStage = getSharedPreferences("game",MODE_PRIVATE).getInt("nowStage",9);
        topstar.setText(String.valueOf(nowStage));


        values = new ArrayList<>();

        for (int i = 1;i <40 ;i++){
            Map<String,Object> map = new HashMap<>();
            map.put("stage",i);
            if(i<10){
                map.put("overFlag",true);
            }else{
                map.put("overFlag",false);
            }
            values.add(map);
        }

        adapter = new GrideAdapter(this,values);
        grid.setAdapter(adapter);

    }
}
